import {messages} from "share/common";
import React, { Component } from 'react';
import 'styles/login/components/voice-code.scss';

class VoiceCode extends Component {
  constructor(props) {
    super(props);
    this.state = {
      status: 'active-my',
    };
  }

  componentDidMount() {
    const { onRef } = this.props;
    onRef && onRef(this);
  }

  reset = () => {
    this.setState({status: 'active-my'});
  }

  sendVoiceCode = (e) => {
    if (this.state.status === 'disabled-my')
      return
    this.setState({status: 'disabled-my'});
    this.props.sendVoiceCode && this.props.sendVoiceCode(e);
  }

  render() {
    const { status } = this.state;
    return (
      <span className={'voice-code'}>
        <span className={`text ${status}`} onClick={this.sendVoiceCode}>
          {messages('basic-2.key87')/*语音验证*/}
        </span>
      </span>
    );
  }
}

export default VoiceCode;
